#ifndef __COMMAND_MAP_H__
#define __COMMAND_MAP_H__

#include <stdio.h>
#include <stdlib.h>

#include "command_map_id.h"

typedef struct {
	char inited;                           //是否已经初始化
	char count;                            //命令词总个数
	command_word_map *map;/*[COMMANDWORDCOUNT]*/;//count个命令词
}command_word_handle;

/**
 * int command_map_init(command_word_handle * handle)
 * @brief init the handle of command_map. memory handle must malloc by user.
 
 * @retval 0 on success. negative_value on failure.
 */
int command_map_init(command_word_handle * handle);

/**
 * int command_map_uninit(command_word_handle * handle)
 * @brief uninit the handle of command_map. 
 
 * @retval 0 on success. negative_value on failure.
 */
int command_map_uninit(command_word_handle * handle);

/**
 * int command_map_get_count()
 * @brief get the number of map_info.
 
 * @retval the count of map_info on success. negative_value on failure.
 */
int command_map_get_count(command_word_handle * handle);


/**
 * int command_map_get(command_word_map * map_buf)
 * @brief get the map_info of SDK.
 * @param[in/out] map_buf, store the map_info. array_size must >= map_count
 
 * @retval process-result, map_num on success. negative_value on failure
 */
int command_map_get(command_word_handle * handle, command_word_map * map_buf);

/**
 * call sample:
 * 1. call 'int map_count = command_map_get_count();' to get the name of command_word_count;
 * 2. malloc memory for map_info: 
 *    int map_size = map_count * sizeof(command_word_map);
 *    command_word_map * map_buf = (command_word_map *)calloc(1, map_size);
 * 3. call 'int ret = command_map_get(map_buf);' to get the map_info
 * 4. when command_word spot, compare the id to word, and response.
 *  if（ret > 1） {
	  //命令词事件，判断是哪个命令词
	  KLOGI(TAG, "command spot success: ");
	 	for (int command_i = 0;command_i<command_map_info.count;command_i++) {
	   if (strcmp(audio_result_main.data_kws[0].word, command_map_info.map[command_i].word) == 0) {
	   	KLOGI(TAG, "command is %s", command_map_info.map[command_i].word);
	   	break;
	   }
	 	}
 *  }
 */

#endif
